﻿using Abp.Application.Navigation;
using Abp.Localization;
using Magicodes.Plus.Web;
using Magicodes.WeChat.Authorization;

namespace Magicodes.WeChat.Web.Mvc
{
    public class WeChatNavigationProvider : NavigationProvider
    {

        public override void SetNavigation(INavigationProviderContext context)
        {
            var menu = context.Manager.Menus[PlusWebConsts.AdminMenuName];
            string area = WeChatConsts.AdminAreaName + "/";
            var rootMenu = new MenuItemDefinition(WeChatPageNames.Common.Roots,
                    L("Roots"),
                    url: "",
                    icon: "fa fa-weixin",
                    requiredPermissionName: WeChatPermissions.Roots,
                    requiresAuthentication: true);


            #region WeChatUser
            rootMenu.Items.Add(new MenuItemDefinition(WeChatPageNames.Common.WeChatUsers,
                    L("WeChatUser"),
                    url: area + "WeChatUsers",
                    icon: "fa fa-users",
                    requiredPermissionName: WeChatPermissions.Roots_Tenants_WeChatUser,
                    requiresAuthentication: true));


            #endregion

            rootMenu.Items.Add(new MenuItemDefinition(WeChatPageNames.Common.Roots_WeChatApiSetting,
                L("WeChatApiSetting"),
                url: area + "WeChatApiSetting",
                icon: "fa fa-weixin",
                requiredPermissionName: WeChatPermissions.Roots_Tenants_WeChatApiSetting,
                requiresAuthentication: true));

            rootMenu.Items.Add(new MenuItemDefinition(WeChatPageNames.Common.Roots_WeChatCustomMenuSetting,
                L("WeChatCustomMenuSetting"),
                url: area + "WeChatCustomMenuSetting",
                icon: "fa fa-cog",
                requiredPermissionName: WeChatPermissions.Roots_Tenants_WeChatApiSetting,
                requiresAuthentication: true));

            menu.AddItem(rootMenu);
        }

        protected static ILocalizableString L(string name)
        {
            return new LocalizableString(name, WeChatConsts.LocalizationSourceName);
        }
    }
}